;(function($) {
	/**
	 * 按钮加载
	 * @param 1. {Boolean} options  是否开启/移除加载状态
	 *        2. {String} options  加载文案
	 * @example: $(btn).loadingBtn(true);
	 */

    $.fn.loadingBtn = function(options) {
        return this.each(function() {
            var $this = $(this),
                textLabel = $this.children().eq(0),
                loader = null;

            if (options) {  // 开启 loading 状态
                $this.prop('disabled', true);
				$this.addClass('is-loading');

                loader = document.createElement('i');
                loader.className = 'icon-loader';
				textLabel.before($(loader));

                if (typeof options === 'string') {
                    $this.attr('data-loading', options);
                }
            } else {  // 移除 loading 状态
                loader = $this.children('i.icon-loader');
                if (loader.length) {
                    loader.remove();
                }
                $this.prop('disabled', false);
                $this.removeClass('is-loading');
            }
        });
    };
})(jQuery);
